package com.abel.bigwater.dataserver.model

import org.springframework.data.annotation.CreatedBy
import org.springframework.data.annotation.CreatedDate
import org.springframework.data.mongodb.core.index.CompoundIndex
import org.springframework.data.mongodb.core.index.CompoundIndexes
import org.springframework.data.mongodb.core.index.Indexed
import org.springframework.data.mongodb.core.mapping.Document
import java.util.*
import kotlin.collections.ArrayList

//@Document(collection = "iwgFlow")
@CompoundIndexes(value = [
    CompoundIndex(name = "fd_recvTime", def = "{'recvTime': 1}"),
    CompoundIndex(name = "fd_station_startTime", def = "{'station': 1, 'startTime': -1}"),
    CompoundIndex(name = "fd_sendTime_sendCount_station_startTime", def = "{'sendTime': -1, 'sendCount': -1, 'station': 1, 'startTime': -1}")
])
data class FlowDataPojo(
        var station: String? = null,

        var fmt: String? = null,

        /** with appended blank ' '.  */
        var devInfoSoft: String? = null,

        /**
         * the count to set
         */
        var count: Short = 0,

        /** in minutes.  */
        var period: Short = 0,

        /** voltage/100.0D V.  */
        var voltage: Int = 0,

        /**
         * one pulse denotes how much water in L.
         */
        var literPulse: Int = 1000,

        /**
         * the uploadTimes to set
         */
        var uploadTimes: Int = 0,

        /**
         * the signal to set
         */
        var signal: Short = 0) {
    /**
     * 接收时间
     */
    @CreatedDate
    @Indexed
    var recvTime: Date? = null

    @CreatedBy
    var createBy: String? = null

    /**
     * 发送次数
     */
    var sendCount: Int = 0

    /**
     * start time of data.
     */
    var startTime: Date? = null

    /**
     * 发送成功时间
     */
    var sendTime: Date? = null

    /**
     * 脉冲列表
     */
    var pulseList = ArrayList<FlowChannelPojo<Number>>()

    /**
     * 模拟列表
     */
    var analogList = ArrayList<FlowChannelPojo<Double>>()

    /**
     * 报警列表
     */
    var warnList = ArrayList<FlowChannelPojo<Short>>()

    var forwardData: FlowChannelPojo<Number>? = null

    var revertData: FlowChannelPojo<Number>? = null

    var netData: FlowChannelPojo<Number>? = null

    var flowData: FlowChannelPojo<Double>? = null

    var pressureData: FlowChannelPojo<Double>? = null

    companion object {
        const val COLLECTION_NAME = "iwgFlow"
    }
}